<script>
  var minCostToMoveChips = function (position) {
    // 偶
    let event = 0;
    // 奇
    let odd = 0;
    position.forEach(el=>{
      if(el%2===0){
        event++;
      }else{
        odd++;
      }
    })
    return Math.min(event,odd);
  };
  console.log(minCostToMoveChips([2,2,2,3,3]));
</script>